package com.zhz.system.repository.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhz.common.tool.mybatisplus.base.dal.entity.BasePO;
import com.zhz.common.tool.mybatisplus.base.dal.repository.impl.BaseRepositoryImpl;
import com.zhz.model.system.UserRole;
import com.zhz.model.system.contract.dto.UserRoleDTO;
import com.zhz.model.system.contract.param.UserRoleQueryParam;
import com.zhz.system.repository.dao.UserRoleDao;
import com.zhz.system.repository.service.UserRoleService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * 用户角色表 服务实现类
 *
 * @author zhouhengzhe
 * @date 2023/4/30
 */
@Service
public class UserRoleServiceImpl extends BaseRepositoryImpl<UserRoleDao, UserRoleDTO, UserRole, UserRoleQueryParam> implements UserRoleService {
    @Override
    protected QueryWrapper<UserRole> getWrapper(UserRoleQueryParam queryParam) {
        return new QueryWrapper<UserRole>()
                .eq(StringUtils.isNotBlank(queryParam.getId()), BasePO.ID, queryParam.getId())
                .eq(StringUtils.isNotBlank(queryParam.getRoleId()), UserRole.ROLE_ID, queryParam.getRoleId())
                .eq(StringUtils.isNotBlank(queryParam.getUserId()), UserRole.USER_ID, queryParam.getUserId());
    }
}
